var options={
	page_id:206,
	grid_id:"gridList",
	sqlname:"grid_206_sys_role_rel_info",
	showCheckbox:false,
	rownumbers:false,
};
//document ready
$(function(){
	grid1=new uniontrip.datagrid.searchEdit(options);
	
	$('#searchButton').bind('click',grid1.load);//查询操作绑定事件
	$('#addButton').bind('click', addRow);//新增行绑定事件
	$('#editButton').bind('click',grid1.editRow);//编辑按钮绑定事件
	$('#removeButton').bind('click',grid1.remove);//删除行绑定事件
	$('#saveButton').bind('click', grid1.accept);//保存datagrid绑定事件
	$('#cancelEditButton').bind('click',grid1.cancelEditing);//取消行编辑绑定事件
	$('#endEditingButton').bind('click', grid1.endEditing);//结束行编辑绑定事件
	$('#rejectButton').bind('click', grid1.rejectChanges);//撤销编辑绑定事件		
    $('#showChangesButton').bind('click',grid1.showChanges);//信息变更提示
    //初始化搜索框
    initsearch();
    //initsessioninfo();
});

/**
 * 新增一行
 */
function addRow(){
	var newRowData={id:guid(),creator_id:sessionuser.id,creator_name:sessionuser.nickname,create_time:moment().format('YYYY-MM-DD')};//初始化行数据
	grid1.grid.datagrid('append',newRowData);	
}

function onDeleteRow(){
	gridConfirm(grid1.grid,"是否确认删除",deleteRow);
}
function deleteRow(row){
	$.post("/authenticated/xx/delete",JSON.stringify({"id":row.id}),function(result){
		if(result.status==200){
			$.messager.alert("提示", "删除成功！");
			grid1.load();
		}else{
			$.messager.alert("提示", "删除失败！<br>"+result.message);
		}
	});
}


/**
 * 初始化搜索条件
 */
function initsearch(){
	/*$('#search-product_class_id').combotree({
		icons: [{
			iconCls:'icon-clear',
			handler:function(){
				$('#search-product_class_id').combotree('clear');
			}
		}],
	    data:grid1.combotreeDatas.product_class_id
	});
	//初始化combobox例子
	$('#search-status').combobox({
		panelHeight:'auto',
		editable:false,
		valueField:'code_value',
		textField:'code_name',
		icons: [{
			iconCls:'icon-clear',
			handler:function(e){
				$(e.data.target).combobox('clear');
			}
		}],
	    data:grid1.comboboxDatas.status
	});*/
}